/*
============================================================================
 Name        : dd_remote_audio_file.c
 Author      : Jian
 Version     :
 Copyright   : GPL
 Description : dd_remote_audio_file.c - source file
============================================================================
*/

/* INCLUDE FILES */
#include "dd_remote_audio_file.h"
#include "dd_log.h"


typedef struct {
    dd_audio_file       funs ;

    int                 id ;

    DD_UINT             size ;
    sd_file*               file ;

    int                 isEof ;

    dd_audio_file_info* info ;

    DD_BYTE*            fileBuffer ;
    DD_UINT             bufOffset ;

} dd_remote_afile;

static int _id(dd_audio_file* pFile)
{
    dd_remote_afile* file = (dd_remote_afile*)pFile ;

    __DD_ASSERT_DEFENSE(file, return -1) ;

    return file->id ;
}

static int _info(dd_audio_file* pFile, const dd_audio_file_info** fileInfo) 
{
    dd_remote_afile* file = (dd_remote_afile*)pFile ;

    __DD_ASSERT_DEFENSE(file, return -1) ;

    if (!file->info) {

    }

    *fileInfo = file->info ;
    return 0 ;
}

static int _decode(dd_audio_file* pFile, dd_pcm_buffer* pcmBuffer) 
{
    dd_remote_afile* file = (dd_remote_afile*)pFile ;

    __DD_ASSERT_DEFENSE(file, return -1) ;
}

static int _tell(dd_audio_file* pFile) 
{
    dd_remote_afile* file = (dd_remote_afile*)pFile ;

    __DD_ASSERT_DEFENSE(file, return -1) ;

}

static int _seek(dd_audio_file* pFile, DD_UINT second) 
{
    dd_remote_afile* file = (dd_remote_afile*)pFile ;

    __DD_ASSERT_DEFENSE(file, return -1) ;
}

static int _is_eof(dd_audio_file* pFile) 
{
    dd_remote_afile* file = (dd_remote_afile*)pFile ;

    __DD_ASSERT_DEFENSE(file, return -1) ;
}

static void _destroy(dd_audio_file* pFile) 
{
    dd_remote_afile* file = (dd_remote_afile*)pFile ;

    __DD_ASSERT_DEFENSE(file, return) ;
}


dd_audio_file* dd_rafile_create(int id)
{
    dd_remote_afile* file = (dd_remote_afile*)dd_malloc(sizeof(dd_remote_afile)) ;

    __DD_CHECK_MEM(file, sizeof(dd_remote_afile), return NULL) ;

    file->funs.id       = _id ;
    file->funs.info     = _info ;
    file->funs.decode   = _decode ;
    file->funs.is_eof   = _is_eof ;
    file->funs.tell     = _tell ;
    file->funs.seek     = _seek ;
    file->funs.destroy  = _destroy ;

    return &(file->funs) ;
}

/* End of File */
